package com.example.demo.service.impl;

import com.example.demo.entity.LoginParam;
import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * @Description :
 * @Author : Bruce Lee
 * @CreateTime : 2023/11/28
 */

@Service
public class DemoServiceImpl implements DemoService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public int register(LoginParam loginParam) {
        User user = new User();
        user.setUserName(loginParam.getUserName());
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        user.setPassWord(bCryptPasswordEncoder.encode(loginParam.getPassWord()));
        int count = userMapper.insert(user);
        return count;
    }
}
